package cn.xorange.commons.system.controller.common;

import cn.xorange.commons.core.basic.bean.ResultBean;
import cn.xorange.commons.security.annotation.PassToken;
import cn.xorange.commons.system.service.impl.SysAreaServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : yangjian
 * date : 2024/2/27
 * description :
 */
@RestController
@RequestMapping("/commons")
public class CommonController {

    @Resource
    SysAreaServiceImpl areaService;

    @PassToken
    @GetMapping("/refreshArea")
    public ResultBean refreshArea(){
        this.areaService.refreshArea();
        return ResultBean.onSuccess();
    }

    @PassToken
    @GetMapping("/getAreaList")
    public ResultBean getAreaList(){
        return ResultBean.onSuccess(this.areaService.getSysAreaList());
    }

    @PassToken
    @GetMapping("/getArea/{id}")
    public ResultBean getArea(@PathVariable(value = "id") String id){
        return ResultBean.onSuccess(this.areaService.getArea(id));
    }
}
